package shanghaielectric.com.shanghaielectric;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 45000460 on 2017/11/6.
 */

public class SecondActivity extends Activity {
    @BindView(R.id.tv_showText2)
    TextView tvShowText;
    @BindView(R.id.button2)
    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_2);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);

    }

    @OnClick(R.id.button2)
    public void onViewClicked() {
        EventBus.getDefault().post("这里是来自activity_2的测试请求");
//        Log.e("event2", "onViewClicked: ");
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void dealMessage(String s) {
        Log.e("eventbus_2", "dealMessage: " + s);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        EventBus.getDefault().unregister(this);
    }
}
